package com.sbpm.util;

import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
import org.springframework.stereotype.Component;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

@Component
public class ApplicationConfiguration
{

    @Bean
    @Qualifier( "jbpmEntityManagerFactory" )
    public EntityManagerFactory getJbpmEntityManagerFactory()
    {
        return Persistence.createEntityManagerFactory( "org.jbpm.persistence.jpa" );
    }


/*
//    @Bean
//    @Qualifier( "crmEntityManagerFactory" )
    public EntityManagerFactory getEntityManagerFactory()
    {
//        LocalContainerEntityManagerFactoryBean managerFactoryBean = new LocalContainerEntityManagerFactoryBean();
//        managerFactoryBean.setPersistenceUnitName( "com.crm.jpa" );
        return Persistence.createEntityManagerFactory( "com.crm.jpa" );
    }*/



    /*@Bean
    @Qualifier( "em" )
    public EntityManager getEntityManager( @Qualifier( "crmEntityManagerFactory" ) EntityManagerFactory crmEntityManagerFactory )
    {
        return crmEntityManagerFactory.createEntityManager();
    }*/



}
